/*
Disclaimer of Warranty: THE PACKAGE IS PROVIDED
BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS'
AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
THE IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT
ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW.
UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF
THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


(c) Copyright 2013 Edward Principe
All Rights Reserved

*/
#ifndef ERRREP_H
#define ERRREP_H

#include <Windows.h>
#include <tchar.h>
#include <iostream>
#include <string>
#include <list>
#include <rex.h>
#include "tokex.h"

using namespace std;

#define VASM_VERSION TEXT("1.00.00")

///////////////////////////////////////////////////////////////////
// ErrRep: Tracks and reports assembler errors
///////////////////////////////////////////////////////////////////
class ErrRep
{
public: // Construction
	ErrRep() { Init(); }

	ErrRep(const ErrRep& rhs)
	{
		Init();
		Copy(rhs);
	}

public: // Methods
	void Set(const ErrRep& rhs);// Set error
	void Set(const TokEx& rhs); // Set error
	void Set(TokErr err = TERR_NONE, unsigned long line = 0, unsigned long col = 0);

public: // Methods
	void Append(const ErrRep& rhs); // Appends class
	void Append(const TokEx& rhs);

public: // Methods
	void Reset()
	{
		_list_errors.erase(_list_errors.begin(), _list_errors.end()); // Erase errors
		Init();
	}

public: // Methods
	list<TokEx>::iterator GetBegin() { return _list_errors.begin(); }
	list<TokEx>::iterator GetEnd() { return _list_errors.end(); }

public: // Methods
	void PrintBanner(); // Prints copyright info
	void PrintReport(); // PrintsReport to stderr

public: // Accessor methods
	unsigned long GetFatalErrors() const { return _fatal_errors; }
	unsigned long GetErrors() const { return _errors; }
	unsigned long GetWarnings() const { return _warnings; }
	unsigned long GetMessages() const { return _messages; }

public: // Operators
	ErrRep& operator = (const ErrRep& rhs)
	{
		Copy(rhs);
		return *this;
	}

	ErrRep& operator += (const ErrRep& rhs)
	{
		Append(rhs);
		return *this;
	}

	ErrRep& operator += (const TokEx& rhs)
	{
		Append(rhs);
		return *this;
	}

	ErrRep& operator + (const ErrRep& rhs)
	{
		Append(rhs);
		return *this;
	}

	ErrRep& operator + (const TokEx& rhs)
	{
		Append(rhs);
		return *this;
	}

private: // Methods
	void Copy(const ErrRep& rhs);
	void Init();
	void CalcErrors(); // Calculates errors

private: // Attribute
	list<TokEx> _list_errors; // Errors
	unsigned long _fatal_errors,
		_errors,
		_warnings,
		_messages;
};
#endif
